package com.sunmnet.j2ee.action.powerdb.designer;

import com.sunmnet.j2ee.action.BaseNewAction;
import com.sunmnet.j2ee.bean.pub.action.JsonResult;
import com.sunmnet.j2ee.bean.pub.action.PageResult;
import com.sunmnet.j2ee.core.pub.QueryFilter;
import com.sunmnet.j2ee.core.pub.annotation.MethodName;
import com.sunmnet.j2ee.entity.powerdb.designer.OperRecord;
import com.sunmnet.j2ee.service.BaseService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

@Controller("/powerdb/designer/operRecord")
@RequestMapping("/powerdb/designer/operRecord")
public class OperRecordAction   extends BaseNewAction<OperRecord,Long> {
    @Override
    @Resource(name ="/powerdb/designer/operRecordService")
    public void setService(BaseService<OperRecord, Long> service) {
        super.service=service;
    }
    /**
     * 批量查询
     *
     * @param request
     * @return JsonResult
     */

    @MethodName(name = "批量查询")
    @RequestMapping(value = "/", method = RequestMethod.PATCH)
    @ResponseBody
    public JsonResult find(HttpServletRequest request){
        QueryFilter filter = new QueryFilter(request);
        return super.find(filter);
    }


    /**
     * 批量查询
     *
     * @param request
     * @return JsonResult
     */

    @MethodName(name = "批量查询")
    @RequestMapping(value = "/pages", method = RequestMethod.PATCH)
    @ResponseBody
    public PageResult findPages (HttpServletRequest request){
        QueryFilter filter = new QueryFilter(request);
        return super.findPages(filter);
    }


    /**
     * 查询
     *
     * @param id
     * @return JsonResult
     */

    @MethodName(name = "对象查询")
    @RequestMapping(value = "/{id}", method = RequestMethod.GET)
    @ResponseBody
    public JsonResult get (@PathVariable("id") long id, HttpServletRequest request){
        return super.get(id);
    }


    /**
     * 新增
     *
     * @param obj
     * @return JsonResult
     */

    @MethodName(name = "新增")
    @RequestMapping(value = "/", method = RequestMethod.POST)
    @ResponseBody
    public JsonResult add (OperRecord obj){
        return super.add(obj);
    }


    /**
     * 更新
     *
     * @param obj
     * @return JsonResult
     */

    @MethodName(name = "修改")
    @RequestMapping(value = "/", method = RequestMethod.PUT)
    @ResponseBody
    public JsonResult update (OperRecord obj){
        return super.update(obj);
    }


    /**
     * 删除
     *
     * @param id
     * @return JsonResult
     */

    @MethodName(name = "删除")
    @RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
    @ResponseBody
    public JsonResult delete ( @PathVariable("id") long id){
        return super.delete(id);
    }


    /**
     * 批量删除
     *
     * @param ids 一个或多个id "1,2,3"
     * @return JsonResult
     */

    @MethodName(name = "批量删除")
    @RequestMapping(value = "/batch", method = RequestMethod.POST)
    @ResponseBody
    public JsonResult batchDelete (@RequestParam(value = "ids", required = true) String ids){
        return super.delete(ids);
    }
}
